Matlab common operation instructions

First, the common object operation: In addition to the usual function keys of the general windows window.

1, !dir can view the files of the current working directory. !dir& can be viewed in the dos state.

2, who can view the current workspace variable name, whos can view the variable name details.

3. Function keys:

Function key shortcut description

Direction key Ctrl+P returns the previous line input

Direction down key Ctrl+N to return to the next line of input

Left arrow Ctrl+B cursor moves backward one character

Right arrow Ctrl+F cursor moves forward one character

Ctrl+directional right Ctrl+R cursor moves one character to the right

Ctrl+direction left key Ctrl+L cursor moves one character to the left

Home Ctrl+A cursor moves to the beginning of the line

End Ctrl+E cursor moves to the end of the line

Esc Ctrl+U clears a line

Del Ctrl+D Clears the character where the cursor is located

Backspace Ctrl+H Delete the previous character of the cursor Ctrl+K Delete to the end of the line

Ctrl+C interrupts the command being executed

4, clc can command the contents of the window display, but does not clear the workspace.

Second, the function and operation

1, the operator:

+: plus, -: minus, *: multiplication, /: except, \: left division ^: power, ': complex conjugate transpose, (): make the order of operations.

2, commonly used function table:

Sin( ) sine (variable is radians)

Cot( ) cotangent (variable is radians)

Sind( ) sine (variable is degree)

Cotd( ) cotangent (variable is degree)

Asin( ) arcsine (return radians)

Acot( ) inverse cotangent (return radians)

Asind( ) arcsine (return degree)

Acotd( ) anti-cotangent (return degree)

Cos( ) cosine (variable is radians)

Exp( ) index

Cosd( ) cosine (variable is degree)

Log( ) logarithm

Acos( ) residual sine (return radians)

Log10( ) takes the base 10 logarithm

Acosd( ) residual sine (return degree)

Sqrt( )

Tan( ) tangent (variable is radians)

Realsqrt( ) returns a non-negative root

Tand( ) tangent (variable is degree)

Abs( ) takes the absolute value

Atan( ) arc tangent (return radians)

Angle( ) returns the phase angle of the complex number

Atand( ) arctangent (return degree)

Mod(x,y) returns the remainder of x/y

Sum( ) vector element summation

3. The rest of the functions can be obtained with the help elfun and help specfun commands.

4, the value of commonly used constants:

Pi 3.1415926.......

Realmin minimum floating point number, 2^-1022

i imaginary unit

Realmax maximum floating point number, (2-eps) 2^1022

j imaginary unit

Inf no limit

Eps floating point relative longitude = 2^-52

NaN null

Matlab common operation instructions

Third, arrays and matrices:

1, the method of constructing an array: incremental and linspace (first, last, num) first and last for the start and end number, num is the number of array elements needed.

2, the method of constructing the matrix: you can directly use [ ] to input the array, you can also use the function provided below to generate the matrix.

Ones( ) creates a matrix with all elements of 1 in which dimensions, 1, 2, ... variables can be formulated

Zeros() creates a matrix with all elements 0

Eye() creates a matrix with a diagonal element of 1 and other elements of 0

Diag() creates a diagonal matrix from the vector, that is, the elements of the vector are diagonal elements

Magic() creates a cube matrix

Rand() creates a random matrix subject to uniform distribution

Randn() creates a random matrix that obeys a normal distribution

Randerm() creates a random row vector

Horcat C=[A,B], horizontal aggregation matrix, can also use cat(1,A,B)

Vercat C=[A;B], vertical aggregation matrix, can also use cat(2,A,B)

Repmat(M,v,h) aggregates the matrix M v times in the vertical direction and aggregates h times in the horizontal direction

Blkdiag(A,B) Create block diagonal matrices with A, and B as blocks

Length returns the length of the longest dimension of the matrix

Ndims returns the dimension

Numel returns the number of matrix elements

Size returns the length of each dimension, [rows,cols]=size(A)

Reshape Reshapes the matrix, reshape(A, 2,6), and transforms A into a 2×6 matrix, arranged in columns.

Rot90 rotation matrix 90 degrees, counterclockwise

Fliplr flips the matrix along the vertical axis

Flipud flip matrix along horizontal axis

Transpose flips the matrix along the main diagonal

Ctranspose transpose matrix, can also use A' or A.', which is only when the matrix is ​​a complex matrix

Inverse of the inv matrix

Determinant value of the det matrix

The sum of the diagonal elements of the trace matrix

Norm norm of a matrix or vector, norm(a,1), norm(a,Inf).......

Normest estimates the maximum norm vector of the matrix

Cholesky decomposition of chol matrix

Cholinc incomplete cholesky decomposition

Lu LU decomposition

Luinc incomplete LU decomposition

Qr orthogonal decomposition

Kron(A,B) A is m×n, and B is p×q, then a matrix of mp×nq is generated. Each element of A is multiplied by B and occupies a space of p×q size.

Rank to find the thorn of the matrix

Pinv pseudo-inverse matrix

A^p operates on A

A.^P operates on each element in A

Fourth, numerical calculation

1. Solving linear equations

(1) The solution of AX=B can be obtained by X=A\B. The solution of XA=B can be obtained by X=A/B. If A is a matrix of m × n, a unique solution can be found when m = n, m n, over-determined system, at least find a set of solutions. If A is singular and AX=B has a solution, you can return the least squares solution with X=pinv(A)×B.

(2) AX=b, A=L×U, [L,U]=lu(A), X=U\(L\b), which is solved by LU decomposition.

(3) QR (orthogonal) decomposition is a product of a matrix represented by an orthogonal matrix and an upper triangular matrix, A = Q × R [Q, R] = chol (A), X = Q \ (U \ b)

(4) cholesky decomposition is similar.

2, the characteristic value

D=eig(A) returns a matrix of all the eigenvalues ​​of A. [V, D] = eig (A), also returns the feature vector matrix.

3. A=U×S×UT, [U, S]=schur(A). The diagonal element of S is the characteristic value of A.

4. The polynomial in the polynomial Matlab is represented by a vector. The specific operation functions are as follows:

Multiplication of conv polynomials

Deconv polynomial division, [a,b]=deconv(s), return quotient and remainder

Poly Find the coefficient of the polynomial (the coefficient of the polynomial from the known root)

Polyeig finds the eigenvalue of a polynomial

Polyfit (x, y, n) Polynomial curve fit, x, y is the fitted vector, and n is the fitted polynomial order.

Polyder finds the first derivative of a polynomial, polyder(a,b) returns the derivative of ab

[a,b]=polyder(a,b) returns the derivative of a/b.

Polyint polynomial integral

Polyval finds the value of a polynomial

Polyvalm finds the value of a polynomial with a matrix as a variable

Residue partial fraction expansion

Roots finds the root of the polynomial (returns the vector of all roots)

Note: Use the feature(A) to find the characteristic polynomial of the matrix, and then find the root, which is the eigenvalue of the matrix.

5. The commonly used interpolation functions for interpolation are as follows:

Griddata data grid blend surface fitting

Griddata3 3D data grid hybrid hypersurface fitting

Interp1 one-dimensional interpolation (yi=interp1(x,y,xi,'method')Method=nearest/linear/spline/pchip/cubic

Interp2 two-dimensional interpolation zi=interp1(x,y,z,xi,yi'method'),bilinear

Interp3 3D interpolation

Interpft performs one-dimensional interpolation with fast Fourier transform, help fft.

Mkpp uses piecewise polynomial

Spline cubic spline interpolation

Pchip piecewise hermit interpolation

6, the solution of the function's maximum value

Fminbnd('f',x1,x2,optiset(,)) finds the minimum value of f between x1 and x2. The Optiset option can have 'Display' + 'iter' / 'off' / 'final', which means that the calculation process is displayed / not displayed / only the last result is displayed. Fminsearch finds the minimum of a multivariate function. Fzero('f',x1) finds the zero of the unary function. X1 is the starting point. The same options as above can be used.

Fifth, image drawing:

1, the basic drawing function

Plot drawing a two-dimensional linear graph and two axes

Plot3 draws a three-dimensional linear graph and two axes

Fplot draws an image of a function in the development interval. Fplot('f', region, line type, color)

Loglog draws a logarithmic graph and two axes (both coordinates are logarithmic) semilogx draws a semi-logarithmic coordinate graph

Semilogy plotting semi-logarithmic coordinates

2, line type: color line type

y yellow. dot line v down arrow

g green -. combination > right arrow

b blue + point is plus sign < left arrow

m red purple o hollow round p pentagram

c blue purple* asterisk h hex star

w white. solid dot hold on add graphics

r red x fork shape grid on add grid

k black s square - solid line

d diamond -- dashed line ^ up arrow

3. Subplot (3, 3, 1) can be used to divide the drawing area into three rows and three columns, and the first region is currently used. At this point, if you want to draw different graphics in a window, you need to hold on.

High Speed Edge Sealing Machine

High Speed Edge Sealing Machine,Woven Bag Small Sealing Machine,Household Woven Bag Sealing Machine,Fully Automatic Woven Bag Sealing Machine

Dongguan Yuantong Technology Co., Ltd. , https://www.ytbagmachine.com